package cn.codeforfun.prize;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by Administrator on 2017/2/15 0015.
 */
@RestController
@RequestMapping("/prize")
public class PrizeController {
    @Autowired
    private PrizeService prizeService;

    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public List list() {
        List<Prize> all = prizeService.findAll();
        return all;
    }

    @RequestMapping("/detail/{id}")
    @ResponseBody
    public Prize detail(@PathVariable Long id) {
        return prizeService.findOne(id);
    }

    @RequestMapping("/save")
    @ResponseBody
    public boolean save(@RequestBody Prize prize) {
        prizeService.save(prize);
        return true;
    }

    @RequestMapping("/exchange")
    @ResponseBody
    public boolean exchange(Integer code) {
        System.out.println(code);
        return true;
    }
}
